define([],function(){
    var tpl = {};
    /*  生活事件量表 --  指导语*/
    tpl.instruction = function(){
        var html = '';
        html += instruction();
        return html;
    };
    var instruction = function(){
        return '<script type="text/html" id="instruction-tpl">'+
                    '<div class="panel panel-default">'+
                        '<div class="panel-heading">指导语</div>'+
                        '<div class="panel-body instruction">'+
                            '<p>{{description}}</p>'+
                        '</div>'+
                        '<div class="panel-heading text-center">'+
                            '<button class="btn btn-info" id="toStart">开始答题</button>'+
                        '</div>'+
                    '</div>'+
                '</script>'
    };
    /*
    * 页面布局盒子：
    * */
    tpl.layoutBox = function(){
        var html = '';
        html += layoutBox();
        return html;
    };
    var layoutBox =  function(){
        return '<script type="text/html" id="layoutBox-tpl">'+
                '<div class="clearfix ques-tabs" id="ques-tabs">'+
                '</div>'+
                '<div class="wrap" id="wrap">'+
                '</div>'+
                '</script>'
    };

    /*  页面布局  */
    tpl.layout = function(){
        var html = '';
        html += layout();
        return html;
    };
    var layout =  function(){
        return '<script type="text/html" id="layout-tpl">'+
                    '<div class="wrap_left" id="wrap_left" style="width:{{width}}">'+
                        '<div class="questionnaire" id="questionnaire">'+
                        '</div>'+
                        '<div class="questionnaire_operate">'+
                            '<div class="add_remark">'+
                                '<button class="btn btn-pri add_remark_btn" id="add_remark_btn">添加备注</button>'+
                            '</div>'+
                            '<div class="clearfix ques-click">'+
                                '<button class="btn btn-pri prev_ques" id="prev_ques" group="prev">上一题</button>'+
                                '<button class="btn btn-pri next_ques pull-right" id="next_ques" group="next">下一题</button>'+
                            '</div>'+
                        '</div>'+
                    '</div>'+
                    '<div class="wrap_right" id="wrap_right">'+
                    '</div>'+
                '</script>'
    };



    /*  右侧答题进度列表*/
    tpl.projectSchedule = function(){
        var html = '';
        html += projectSchedule();
        return html;
    };
    var projectSchedule = function(){
        return '<script type="text/html" id="projectSchedule-tpl">'+
                '<div class="panel panel-default">'+
                    '<div class="panel-heading text-center">答题进度</div>'+
                    '<div class="panel-body p-0">'+
                        '<ul class="project_schedule">'+
                            '{{each data as value,i}}'+
                            '<li {{if i == 0}} class="doing" {{/if}} {{if value.group}}group ="{{value.group}}"{{/if}}>{{value.title}}</li>'+
                            '{{/each}}'+
                        '</ul>'+
                    '</div>'+
                '</div>'+
            '</script>'
    };
    /*
    * 加载题目：OSI
    * */
    tpl.questionType2 = function(){
        var html = '';
        html += singleElectionOsi();
        html += blankOsi();
        html += blankList();
        html += single();
        html += blank();
        html += list();
        html += blankSingle();
        html += linkage();
        html += extralMark();
        html += questionType2();
        return html;
    };
    var questionType2 = function(){
        return '<script type="text/html" id="questionType2-tpl">'+
                '{{if type == "single" || type == "checkbox"}}'+
                    '{{include "singleElectionOsi-tpl" }}'+
                '{{else if type == "blank"}}'+
                    '{{include "blankOsi-tpl" }}'+
                '{{else if type == "blankList"}}'+
                    '{{include "blankList-tpl" }}'+   
                '{{else if type == "linkage"}}'+
                    '{{include "linkage-tpl" }}'+
                '{{/if}}'+
                '<div class="remarks" id="remarks">'+
                    '{{include "extralMark-tpl" }}'+
                '</div>'+
            '</script>'
    };


    tpl.extralMark = function(){
        var html = '';
        html += extralMark();
        return html;
    };
    /*  备注  */
    var extralMark = function(){
        return '<script type="text/html" id="extralMark-tpl">'+
                '{{each extra as value,i}}'+
                '<div class="panel panel-default remark" num = "{{value.num}}">'+
                    '<div class="panel-heading">备注{{value.num}}</div>'+
                    '<div class="panel-body">'+
                        '<textarea name="remark"  class="form-control" placeholder="请输入相关备注">{{value.text}}</textarea>'+
                    '</div>'+
                '</div>'+
                '{{/each}}'+
                '</script>'
    };
    /* 问卷题型 */
    /*
    * 联动：
     */
    var linkage = function(){
        return '<script type="text/html" id="linkage-tpl">'+
                    '<div class="panel panel-default" id="{{id}}" number="{{listNo}}" type="{{type}}" quesType="osi">'+
                        '<div class="panel-heading">{{itemTitle}}</div>'+
                        '<div class="panel-body">'+
                            '{{each list as li,i}}'+
                                '{{if li.type == "single" || li.type == "checkbox"}}'+
                                    '{{include "single-tpl" li}}'+
                                '{{else if li.type == "blank"}}'+
                                    '{{include "blank-tpl" li}}'+
                                '{{else if li.type == "blankList"}}'+
                                    '{{include "list-tpl" li}}'+
                                '{{else if li.type == "blankSingle"}}'+
                                    '{{include "blankSingle-tpl" li}}'+
                                '{{/if}}'+
                            '{{/each}}'+    
                        '</div>'+
                    '</div>'+
            '</script>'
    } 
    /*//数字：
    var number_axis = function(){
        return '<scprit type = "text/html" id="number_axis-tpl">'+
                '{{each data as value,i}}'+
                    '<div class="time_day" style="width:"><span class="time_axis"></span><span class="time_val">25</span></div>'+
                '{{/each}}'+
                '</script>'
    };
    var menstrualCycle = function(){
        return '<script type="text/html" id="menstrualCycle-tpl">'+
                '<div class="panel panel-default">'+
                    '<div class="panel-heading">月经婚育史</div>'+
                    '<div class="panel-body">'+
                        '<div class="ques">'+
                            ' <span class = "ques_num">2.2</span>既往月经周期 <input type="text" class="underline"/>天 <span  class="warn">(*几天来一次)</span>'+
                       '</div>'+
                        '<div class="time_base">'+
                            '<div class="checked_time"><span class="end_circle"></span></div>'+
                            '<div class="clearfix menstrual">'+
                                '{{include "number_axis-tpl" data.data}}'+
                                /!*'<div class="time_day"><span class="time_axis"></span><span class="time_val">25</span></div>'+
                                '<div class="time_day"><span class="time_axis"></span><span class="time_val">26</span></div>'+
                                '<div class="time_day"><span class="time_axis"></span><span class="time_val">27</span></div>'+
                                '<div class="time_day"><span class="time_axis"></span><span class="time_val">28</span></div>'+
                                '<div class="time_day"><span class="time_axis"></span><span class="time_val">29</span></div>'+
                                '<div class="time_day"><span class="time_axis"></span><span class="time_val">30</span></div>'+
                                '<div class="time_day"><span class="time_axis"></span><span class="time_val">31</span></div>'+
                                '<div class="time_day"><span class="time_axis"></span><span class="time_val">32</span></div>'+
                                '<div class="time_day"><span class="time_axis"></span><span class="time_val">33</span></div>'+
                                '<div class="time_day"><span class="time_axis"></span><span class="time_val">34</span></div>'+
                                '<div class="time_day"><span class="time_axis"></span><span class="time_val">35</span></div>'+*!/
                            '</div>'+
                        '</div>'+
                    '</div>'+
                '</div>'+
            '</script>'
    }
    // 日期地点
    var dateAndPosition = function(){
        return '<script type="text/html" id="dateAndPosition-tpl">'+
                    '<div class="panel panel-default">'+
                        '<div class="panel-heading">月经婚育史</div>'+
                        '<div class="panel-body">'+
                            '<div class="clearfix ques">'+
                                '<div class="left ques-date ques_num">2.2</div>'+
                                '<div class="left">'+
                                    '<div class="ques-date-row">末次月经 <input type="date" class="form-control w-150"/> <span  class="warn">（*上次月经第一天，包括使用药物产生月经）</span></div>'+
                                    '<div class="ques-date-row">前次月经 <input type="date" class="form-control w-150"/> <span  class="warn">（*上上次月经第一天）</span></div>'+
                                '</div>'+
                            '</div>'+
                        '</div>'+
                    '</div>'+
                '</script>'
    };*/
    var blank = function(){
        return '<script type="text/html" id="blank-tpl">'+
                    '<div id="{{id}}" type="{{type}}" {{if !value}} {{if css == "none"}}style="display:none"{{/if}}{{/if}}>'+
                        '<div class="ques" >'+
                            '{{each description as val,i}}'+
                                '{{if val.item == "text"}}'+
                                    '<input type="text" class="form-control w-150" value="{{value}}">'+
                                '{{else if val.item == "number"}}'+
                                    '<input type="number" class="form-control w-150" min="0" value="{{value}}">'+
                                '{{else if val.item == "time"}}'+
                                    '<input type="time" class="form-control w-150" min="8:00" {{if value}} value="{{value}}" {{else}} value="00:00" {{/if}}>'+
                                '{{else if val.item == "date"}}'+
                                '<input type="date" class="form-control w-150"  value="{{value}}">'+
                                '{{else}}'+
                                    '{{val.item}}'+
                                '{{/if}}'+
                            '{{/each}}'+
                            '{{bak}}'+
                        '</div>'+
                    '</div>'+
            '</script>'
    }
    var list = function(){
        return '<script type="text/html" id="list-tpl">'+
                    '<div id="{{id}}" type="{{type}}" {{if !value}}{{if css == "none"}}style="display:none"{{/if}}{{/if}}>'+
                        '<div class="ques">'+
                            '{{each description as value,i}}'+
                                '{{if value.item == "text"}}'+
                                   /* '<input type="text" class="form-control w-150">'+*/
                                '{{else if value.item == "number"}}'+
                                    /*'<input type="number" class="form-control w-150" min="0">'+*/
                                '{{else}}'+
                                    '{{value.item}}'+
                                '{{/if}}'+
                            /*'<span class = "ques_num"></span>'+*/
                            '{{/each}}'+
                        '</div>'+
                        '<div class="blankList">'+
                            '<div class="clearfix">'+
                                '{{if value}}'+
                                    '{{each value as val,i}}'+
                                        '<textarea class="pull-left form-control blank_text" placeholder="请输入具体内容">{{val.val}}</textarea>'+
                                        '{{if val.no == valueLens}}'+
                                        '<button class="btn btn-pri" id="addBlank">添加</button>'+
                                        '{{/if}}'+
                                    '{{/each}}'+
                                '{{else}}'+
                                    '<textarea class="pull-left form-control blank_text" placeholder="请输入具体内容"></textarea>'+
                                    '<button class="btn btn-pri" id="addBlank">添加</button>'+
                                '{{/if}}'+
                            '</div>'+
                        '</div>'+
                    '</div>'+
            '</script>'
    }
    var single = function(){
        return '<script type="text/html" id="single-tpl">'+
                    '<div id="{{id}}" type="{{type}}" {{if !value}}{{if css == "none"}}style="display:none"{{/if}}{{/if}}>'+
                        '<div class="ques">'+
                            '<span class = "ques_num">{{description}}</span>'+
                        '</div>'+
                        '<div class="clearfix ques_single_tab" {{if choose}}choose="{{choose}}" link="{{link}}" link0 = "{{link0}}" link1 = "{{link1}}" {{/if}}>'+
                            '{{each option as op,i}}'+
                            '<div class="linkage_tab {{if op.flag == 1}}link_checked {{/if}}" name = "{{op.item}}">{{op.val}}</div>'+
                            '{{/each}}'+
                        '</div>'+
                    '</div>'+
                '</script>'
    };
    var blankSingle = function(){
        return '<script type="text/html" id="blankSingle-tpl">'+
                '<div id="{{id}}" type="{{type}}" {{if !value}}{{if css == "none"}}style="display:none"{{/if}}{{/if}}>'+
                    '<div class="ques">'+
                        '{{each description as val,i}}'+
                            '{{if val.item == "text"}}'+
                                '<input type="text" class="form-control w-150" value="{{value}}">'+
                            '{{else if val.item == "number"}}'+
                                '<input type="number" class="form-control w-150" min="0" value="{{value}}">'+
                            '{{else if val.item == "time"}}'+
                                '<input type="time" class="form-control w-150" min="8:00" {{if value}} value="{{value}}" {{else}} value="00:00" {{/if}}>'+
                            '{{else if val.item == "date"}}'+
                                '<input type="date" class="form-control w-150"  value="{{value}}">'+
                            '{{else}}'+
                                '{{val.item}}'+
                            '{{/if}}'+
                        '{{/each}}'+
                        '{{bak}}'+
                    '</div>'+
                    '<div class="clearfix inputNo"  {{if !values }}style="display:none;"{{/if}}>'+
                        '{{each values as op,i}}'+
                            '<input type="date" class="form-control w-150"  value="{{op.val}}">'+
                        '{{/each}}'+
                    '</div>'+
                    '<div class="clearfix ques_single_tab" style="display:none;">'+
                        '{{each option as op,i}}'+
                        '<div class="linkage_tab {{if op.flag == 1}}link_checked {{/if}}" name = "{{op.item}}">{{op.val}}</div>'+
                        '{{/each}}'+
                    '</div>'+
                '</div>'+
            '</script>'
    }
    //填空：
    var blankOsi = function(){
        return '<script type="text/html" id="blankOsi-tpl">'+
                    '<div class="panel panel-default" id="{{id}}" number="{{listNo}}"  type="{{type}}" quesType="osi">'+
                        '<div class="panel-heading">{{itemTitle}}</div>'+
                        '<div class="panel-body">'+
                            '<div class="ques">'+
                                '{{each description as val,i}}'+
                                    '{{if val.item == "text"}}'+
                                        '<input type="text" class="form-control w-150" value="{{value}}">'+
                                    '{{else if val.item == "number"}}'+
                                        '<input type="number" class="form-control w-150" min="0" value="{{value}}">'+
                                    '{{else if val.item == "time"}}'+
                                        '<input type="time" class="form-control w-150"  value="{{value}}">'+
                                    '{{else if val.item == "date"}}'+
                                    '<input type="date" class="form-control w-150"  value="{{value}}">'+
                                    '{{else}}'+
                                        '{{val.item}}'+
                                    '{{/if}}'+
                                '{{/each}}'+
                                '{{bak}}'+
                            '</div>'+
                        '</div>'+
                    '</div>'+
            '</script>'
    };
    var blankList = function(){
        return '<script type="text/html" id="blankList-tpl">'+
                    '<div class="panel panel-default" id="{{id}}" number="{{listNo}}" length="{{length}}" type="{{type}}" quesType="osi">'+
                        '<div class="panel-heading">{{itemTitle}}</div>'+
                        '<div class="panel-body">'+
                            '<div class="ques">'+
                                '{{each description as value,i}}'+
                                    '{{if value.item == "text"}}'+
                                       /* '<input type="text" class="form-control w-150">'+*/
                                    '{{else if value.item == "number"}}'+
                                        /*'<input type="number" class="form-control w-150" min="0">'+*/
                                    '{{else}}'+
                                        '{{value.item}}'+
                                    '{{/if}}'+
                                /*'<span class = "ques_num"></span>'+*/
                                '{{/each}}'+
                            '</div>'+
                            '<div class="blankList">'+
                                '{{if value}}'+
                                    '{{each value as val,i}}'+
                                        '<div class="clearfix">'+
                                            '<textarea class="pull-left form-control blank_text" placeholder="请输入具体内容">{{val.val}}</textarea>'+
                                            '{{if val.no == valueLens}}'+
                                            '<button class="pull-left btn btn-pri" id="addBlank">添加</button>'+
                                            '{{/if}}'+
                                        '</div>'+
                                    '{{/each}}'+
                                '{{else}}'+
                                    '<div class="clearfix">'+
                                        '<textarea class="pull-left form-control blank_text" placeholder="请输入具体内容"></textarea>'+
                                        '<button class="btn btn-pri" id="addBlank">添加</button>'+
                                    '</div>'+
                                '{{/if}}'+
                            '</div>'+
                        '</div>'+
                    '</div>'+
            '</script>'
    };
    //osi单选：
    var singleElectionOsi = function(){
        return '<script type="text/html" id="singleElectionOsi-tpl">'+
                    '<div class="panel panel-default" id="{{id}}" length="{{length}}" number="{{listNo}}"  type="{{type}}" quesType="osi">'+
                        '<div class="panel-heading">{{itemTitle}}</div>'+
                        '<div class="panel-body">'+
                            '<div class="ques">'+
                                '<span class = "ques_num">{{description}}</span>'+
                            '</div>'+
                            '<div class="clearfix ques_single_tab">'+
                                '{{each option as op,i}}'+
                                '<div class="linkage_tab {{if op.flag == 1}}link_checked {{/if}}" name = "{{op.item}}">{{op.val}}</div>'+
                                '{{/each}}'+
                            '</div>'+
                            '<div class="extralSingle">'+
                                '{{if extralSingle}}'+
                                '请填写：<input type="text" class="form-control w-150"  name="{{if extralName}}{{extralName}} {{else}}{{value}} {{/if}}" value="{{extralSingle}}">'+
                                '{{/if}}'+
                            '</div>'+
                        '</div>'+
                    '</div>'+
                '</script>'
    };

    /*
    *  提交弹窗：
     */
    tpl.toSubmit = function(){
        var html = '';
        html += toSubmit();
        return html;
    };
    var toSubmit = function(){
        return '<script type="text/html" id="toSubmit-tpl">'+
                    '<div class="modal fade {{className}}" tabindex="-1" role="dialog" >'+
                        '<div class="modal-dialog" role="document">'+
                            '<div class="modal-content">'+
                                '<div class="modal-body">'+
                                '</div>'+
                            '</div>'+
                        '</div>'+
                    '</div>'+
                '</script>'
    };

    /*
    * 提交弹窗：
     */
    tpl.lesSubmit = function(){
        var html = "";
        html += lesSubmit();
        return html;
    };
    var lesSubmit = function(){
        return '<script type="text/html" id="lesSubmit-tpl">'+
                    '<div class="text-center tips">'+
                       '基础事件全部完成'+
                    '</div>'+
                    '<div class="clearfix btnGroup">'+
                        '<button class="btn btn-default" id="backModify">返回修改</button>'+
                        '<button class="btn btn-pri pull-right" id="toSubmit">去提交</button>'+
                    '</div>'+
                '</script>'
    };
    return tpl;
});